﻿Imports Infragistics.Win
Imports Crystal.CLL
Imports CrystalClientManagement.BLL
Imports Infragistics.Win.UltraWinEditors
Imports System.Text
Imports Infragistics.Win.UltraWinGrid
Imports Microsoft.Practices.EnterpriseLibrary.Logging
Imports Infragistics.Win.UltraWinToolTip

Public Class frmAddEditClient
#Region "Declare"
    Public clientID As String = String.Empty
    Private IsLoading As Boolean = False
    Private IsSaved As Boolean = False
    Public Event AddParticularClientInGrid(ByVal ClientId As Integer)
    'Public Delegate Sub DropdownItemSelectedEventHandler(ByVal sender As Object, ByVal e As DropdownItemSelectedEventArgs)
    'Public Event DropdownItemSelected As DropdownItemSelectedEventHandler
#End Region

#Region "Properties"
    Public Property Client() As String
        Get
            Return clientID
        End Get
        Set(ByVal value As String)
            clientID = value
        End Set
    End Property
#End Region

#Region "Constructor"

    Public Sub New()
        InitializeComponent()
        GetValidatedControls()
        DisableRightClickInTextBox()
    End Sub

#End Region

#Region "FormLoad"

    Private Sub frmAddEditClient_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Not IsSaved Then
            If Client = String.Empty Then
                If IsContentChange() Then
                    If (MessageBox.Show("Do you want to save the client?", BaseClass.crystalCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = Windows.Forms.DialogResult.OK) Then
                        ValidationManager.IsButtonClick = True
                        If IsValid() Then
                            e.Cancel = True
                            Exit Sub
                        End If
                        'If IsEmptyControl() Then
                        '    e.Cancel = True
                        '    Exit Sub
                        'End If
                        btnSave.PerformClick()
                        If Not IsSaved Then
                            e.Cancel = True
                        End If
                    End If
                End If
            Else
                If IsClientcontentChange() Then
                    If (MessageBox.Show("Do you want to save the changes?", BaseClass.crystalCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = Windows.Forms.DialogResult.OK) Then
                        ValidationManager.IsButtonClick = True
                        If IsValid() Then
                            e.Cancel = True
                            Exit Sub
                        End If
                        'If IsEmptyControl() Then
                        '    e.Cancel = True
                        '    Exit Sub
                        'End If
                        btnSave.PerformClick()
                        If Not IsSaved Then
                            e.Cancel = True
                        End If
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub frmAddEditClient_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        IsLoading = True
        InitControls()
        If Client <> String.Empty Then
            IsLoading = False
            SetClientDetail()
        End If
        'grdClientDetail.Focus()
        IsLoading = False
        SetDesignComboControl()
    End Sub
#End Region

#Region "Method"

    Private Sub SetDesignComboControl()
        cmbCapGroup.Appearance.ForeColor = Color.Black
        cmbCity.Appearance.ForeColor = Color.Black
        cmbCountry.Appearance.ForeColor = Color.Black
        cmbIndustry.Appearance.ForeColor = Color.Black
        cmbListing.Appearance.ForeColor = Color.Black
        cmbPExchange.Appearance.ForeColor = Color.Black
        cmbSector.Appearance.ForeColor = Color.Black
        cmbState.Appearance.ForeColor = Color.Black
    End Sub

    Private Sub InitControls()
        InitCombos()
        LoadListingData()
        BindListingGridClient()
        BindCapGroup()
        LoadClientAdditionalDetail()
        DefaultDisableButton()
        btnUpList.Enabled = False
    End Sub
    Private Sub DefaultDisableButton()
        If grdClientDetail.Rows.Count > 1 Then
            btnUpList.Enabled = True
            btnDownList.Enabled = True
        Else
            btnUpList.Enabled = False
            btnDownList.Enabled = False
        End If
    End Sub
    Private Sub BindCapGroup()
        cmbCapGroup.DisplayMember = "CapGroup"
        cmbCapGroup.DataSource = GetCapGroupData()
        cmbCapGroup.SelectedIndex = -1
        'cmbCapGroup.SelectedItem = String.Empty
    End Sub
    Private Sub LoadClientAdditionalDetail()
        Dim dataSet As New DataSet
        Try
            dataSet = AddEditClient.GetClientAdditionalDetail()
            BindAdditionalDetail(dataSet)

        Catch ex As Exception
            Throw ex
            Dim MsgLog As New System.Text.StringBuilder
            MsgLog.Append("There is error in LoadClientAdditionalDetail in Client Management.")
            MsgLog.Append(Environment.NewLine)
            MsgLog.Append("Error Details:- ")
            MsgLog.Append(ex.ToString())
            CreateErrorLog(MsgLog)
            MsgLog = Nothing
        Finally
            dataSet = Nothing
        End Try
    End Sub
    Public Sub CreateErrorLog(ByVal Message As System.Text.StringBuilder)
        Dim Log As LogEntry = Nothing
        Try
            Log = New LogEntry
            Message.Append(Environment.NewLine)
            Message.Append("Local Machine Date/Time - ")
            Message.Append(Now.Date.Day.ToString)
            Message.Append("/")
            Message.Append(Now.Date.Month.ToString)
            Message.Append("/")
            Message.Append(Now.Date.Year.ToString)
            Message.Append("  (DD-MM-YYYY)  ")
            Message.Append(DateTime.Now.Hour.ToString)
            Message.Append(":")
            Message.Append(DateTime.Now.Minute.ToString)
            Message.Append(":")
            Message.Append(DateTime.Now.Second.ToString)
            Message.Append(Environment.NewLine)
            Log.Message = Message.ToString()
            Logger.Write(Log)

        Catch ex As Exception
            MessageBox.Show(ex.Message)

        Finally
            Log = Nothing
            Message = Nothing
        End Try
    End Sub
    Private Sub BindAdditionalDetail(ByVal dset As DataSet)
        cmbSector.DataSource = dset.Tables(AddEditClient.ClientAdditionalDetail.Sector)
        cmbIndustry.DataSource = dset.Tables(AddEditClient.ClientAdditionalDetail.Industry)
        cmbPExchange.DataSource = dset.Tables(AddEditClient.ClientAdditionalDetail.Exchange)
        cmbCountry.DataSource = dset.Tables(AddEditClient.ClientAdditionalDetail.Country)

        cmbSector.SelectedIndex = AddEditClient.selectedValue
        cmbIndustry.SelectedIndex = AddEditClient.selectedValue
        cmbPExchange.SelectedIndex = AddEditClient.selectedValue
        cmbCountry.SelectedIndex = AddEditClient.selectedValue
    End Sub
    Private Sub InitCombos()
        cmbSector.DisplayMember = "Sector"
        cmbSector.ValueMember = "SectorID"

        cmbIndustry.DisplayMember = "Industry"
        cmbIndustry.ValueMember = "IndustryID"

        cmbPExchange.DisplayMember = "Exchange"
        cmbPExchange.ValueMember = "ExchangeID"

        cmbCountry.DisplayMember = "CountryName"
        cmbCountry.ValueMember = "countryID"
    End Sub
    Private Sub LoadListingData()
        Dim dataSet As New DataSet
        Dim Logmessage As New System.Text.StringBuilder
        Dim dataTable As New DataTable
        Try
            dataSet = AddEditClient.GetClientData()
            dataTable = dataSet.Tables(0)
            Dim dataRow As DataRow = dataTable.Rows(5)
            dataTable.Rows.Remove(dataRow)
            dataRow = dataTable.NewRow()
            dataRow.Item("Listing") = "--New--"
            dataTable.Rows.InsertAt(dataRow, 0)
            dataTable = BaseClass.BlankRowAtLastDataTable(dataTable)
            cmbListing.DataSource = dataTable
        Catch ex As Exception
            Throw ex
            Logmessage.Append("There is error in LoadListingData of form AddEdit.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
            dataTable = Nothing
            Logmessage = Nothing
        End Try
    End Sub
    Private Sub FillCityStateRegion()
        Dim dtable As New DataTable
        Dim dset As DataSet = Nothing
        Dim Logmessage As New System.Text.StringBuilder
        Try
            cmbCity.Enabled = True
            cmbCity.DisplayMember = "City"
            cmbCity.ValueMember = "CityID"
            dset = AddEditClient.GetCityStateRegion(cmbCountry.Value)
            cmbCity.DataSource = dset.Tables(AddEditClient.CityStateTable.City)
            cmbCity.SelectedIndex = AddEditClient.selectedValue

            '''''''''''''''''''''''''''''''''''State..........................
            If (cmbCountry.Text.ToLower().Contains("united states") = True Or cmbCountry.Text.ToString().ToLower().Contains("canada")) Then
                cmbState.Enabled = True
                cmbState.DisplayMember = "State"
                cmbState.ValueMember = "StateID"
                cmbState.DataSource = dset.Tables(AddEditClient.CityStateTable.State)
                cmbState.SelectedIndex = AddEditClient.selectedValue
                '''''''''''''''''''''''''''''''''''''''City..........................
            Else
                cmbState.SelectedIndex = AddEditClient.selectedValue
                cmbState.Enabled = False
            End If

            txtRegion.Text = dset.Tables(AddEditClient.CityStateTable.Region).Rows(0)("Region").ToString

        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in FillCityStateRegion of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dset = Nothing
        End Try
    End Sub
    Private Sub SetClientData(ByVal data As DataTable)
        If data.Rows.Count > 0 Then
            txtClientName.Text = data.Rows(0)("ClientName").ToString
            cmbSector.Value = data.Rows(0)("SectorID").ToString
            cmbIndustry.Value = data.Rows(0)("IndustryID").ToString
            txtMarketCap.Text = data.Rows(0)("MarketCap").ToString
            cmbCapGroup.Text = data.Rows(0)("CapGroup").ToString
            cmbPExchange.Value = data.Rows(0)("PrimaryExchangeID").ToString
            txtStreet1.Text = data.Rows(0)("Street1").ToString
            txtStreet2.Text = data.Rows(0)("Street2").ToString
            cmbCountry.Value = data.Rows(0)("CountryID").ToString
            cmbCity.Value = data.Rows(0)("CityID").ToString
            cmbState.Value = data.Rows(0)("StateID").ToString
            txtPostalCode.Text = data.Rows(0)("PostalCode").ToString
            txtMobile.Text = data.Rows(0)("MobileNumber").ToString
            txtTelephone.Text = data.Rows(0)("TelNumber").ToString
            txtExt.Text = data.Rows(0)("Extension").ToString
            txtEmail.Text = data.Rows(0)("EmailAddress").ToString
            txtFax.Text = data.Rows(0)("FaxNumber").ToString
            txtNotes.Text = data.Rows(0)("Notes").ToString
        End If
    End Sub
    Private Sub SetClientListing(ByVal listing As DataTable)
        If listing IsNot Nothing Then
            If listing.Rows IsNot Nothing Then
                If listing.Rows.Count > 0 Then
                    grdClientDetail.DataSource = listing
                End If
            End If
        End If
    End Sub
    Private Function IsValid() As Boolean
        If Not (Me.ValidateChildren()) Then
            ValidationManager.IsButtonClick = False
            'FocusOnEmptyControl()
            Return True
        End If
        ValidationManager.IsButtonClick = False
        Return False
    End Function
    Private Sub SetClientDetail()
        Dim Logmessage As New System.Text.StringBuilder
        Dim isValid As Boolean = False
        Dim Id As Integer = 0
        Dim dataSet As New DataSet
        Try
            isValid = Integer.TryParse(Client, Id)
            If isValid Then
                dataSet = AddEditClient.GetClientDetail(Id)
                If dataSet IsNot Nothing Then
                    SetClientData(dataSet.Tables(AddEditClient.ClientDetail.Client))
                    SetClientListing(dataSet.Tables(AddEditClient.ClientDetail.Listing).Copy())
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in SetClientDetail of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            dataSet = Nothing
        End Try
    End Sub
    Private Function IsEmptyControl() As Boolean
        If txtStreet1.Text = String.Empty Or txtStreet2.Text = String.Empty Or txtPostalCode.Text = String.Empty Or txtMobile.Text = String.Empty _
            Or txtTelephone.Text = String.Empty Or txtExt.Text = String.Empty Or txtEmail.Text = String.Empty Or txtNotes.Text <> "Notes" Or txtNotes.Text = String.Empty _
            Then
            Return True
        End If
        Return False
    End Function
    Private Function IsChangeInGrid() As Boolean
        Dim ldtProjects As DataTable
        ldtProjects = (CType(grdClientDetail.DataSource, DataTable))
        For i As Integer = 0 To ldtProjects.Rows.Count - 1
            If Not CommonCLL.blnRowBlank(ldtProjects.Rows(i)) Then
                Return True
            End If
        Next
        Return False
    End Function
    Private Function IsContentChange() As Boolean
        If (txtClientName.Text <> "Client Name" And txtClientName.Text <> String.Empty) Or (cmbSector.Value <> AddEditClient.selectedValue And cmbSector.Value <> Nothing) Or (cmbIndustry.Value <> AddEditClient.selectedValue And cmbIndustry.Value <> Nothing) _
            Or txtMarketCap.Text <> String.Empty Or cmbCapGroup.Text <> String.Empty Or (cmbPExchange.Value = AddEditClient.selectedValue And cmbPExchange.Value <> Nothing) _
            Or txtStreet1.Text <> String.Empty Or txtStreet2.Text <> String.Empty Or cmbCountry.Value = AddEditClient.selectedValue _
            Or txtPostalCode.Text <> String.Empty Or txtMobile.Text <> String.Empty Or txtTelephone.Text <> String.Empty Or txtExt.Text <> String.Empty _
            Or txtEmail.Text <> String.Empty Or IsChangeInGrid() Then
            Return True
        End If
        Return False
    End Function

    Private Sub MultiRowSelection(ByVal isTrue As Boolean)
        btnUpList.Enabled = isTrue
        btnDownList.Enabled = isTrue
    End Sub

    Private Sub EnableDisableUpDownButtons()
        DefaultDisableButton()
        If grdClientDetail.ActiveRow.Index = 0 Then
            btnUpList.Enabled = False
        Else
            btnUpList.Enabled = True
        End If
        If grdClientDetail.ActiveRow.Index = grdClientDetail.Rows.Count - 1 Then
            btnDownList.Enabled = False
        Else
            btnDownList.Enabled = True
        End If
    End Sub

    Private Function IsClientcontentChange() As Boolean
        Dim dataSet As New DataSet
        dataSet = AddEditClient.GetClientDetail(clientID)
        If txtClientName.Text <> dataSet.Tables(0).Rows(0)("ClientName").ToString Or cmbSector.Value <> dataSet.Tables(0).Rows(0)("SectorID").ToString _
            Or cmbIndustry.Value <> dataSet.Tables(0).Rows(0)("IndustryID") Or cmbCapGroup.Text <> dataSet.Tables(0).Rows(0)("CapGroup").ToString _
            Or cmbPExchange.Value <> dataSet.Tables(0).Rows(0)("PrimaryExchangeID").ToString _
            Or txtMarketCap.Text <> dataSet.Tables(0).Rows(0)("MarketCap").ToString Or txtStreet1.Text <> dataSet.Tables(0).Rows(0)("Street1").ToString _
            Or txtStreet2.Text <> dataSet.Tables(0).Rows(0)("Street2").ToString Or cmbCity.Value <> dataSet.Tables(0).Rows(0)("CityId").ToString _
            Or cmbState.Value <> dataSet.Tables(0).Rows(0)("StateID").ToString Or cmbCountry.Value <> dataSet.Tables(0).Rows(0)("CountryID").ToString _
            Or txtPostalCode.Text <> dataSet.Tables(0).Rows(0)("PostalCode").ToString Or txtMobile.Text <> dataSet.Tables(0).Rows(0)("MobileNumber").ToString _
            Or txtTelephone.Text <> dataSet.Tables(0).Rows(0)("TelNumber").ToString Or txtFax.Text <> dataSet.Tables(0).Rows(0)("FaxNumber").ToString _
            Or txtEmail.Text <> dataSet.Tables(0).Rows(0)("EmailAddress").ToString Or txtNotes.Text <> dataSet.Tables(0).Rows(0)("Notes").ToString _
            Or txtExt.Text <> dataSet.Tables(0).Rows(0)("Extension").ToString Or CreateListingXML(CType(grdClientDetail.DataSource, DataTable)).ToString <> CreateListingXML(dataSet.Tables(1)).ToString Then
            Return True
        End If
        Return False
    End Function
#End Region

#Region "Validation"

    Private Sub GetValidatedControls()
        ValidateControls(CType(pnlGeneralInfo.Controls(0), Misc.UltraPanelClientArea).Controls, True)
        RequiredValidateControl(txtClientName, "Client name")
        RequiredValidateControl(cmbCountry, "Country")
        'RangeValidator(txtMarketCap, "9223372036854775807", "0", lblMarket.Text)
        ApplyRegexValidation(txtMobile, ValidationManager.RegexType.Telephone, "Mobile Number")
        ApplyRegexValidation(txtFax, ValidationManager.RegexType.Telephone, "Fax")
        ApplyRegexValidation(txtTelephone, ValidationManager.RegexType.Telephone, "TelephoneNumber")
        ApplyRegexValidation(txtPostalCode, ValidationManager.RegexType.Telephone, "Postal Code")
        ApplyRegexValidation(txtEmail, ValidationManager.RegexType.Email, "Email")
        ApplyRegexValidation(txtExt, ValidationManager.RegexType.Numeric, "Extension")
    End Sub

#End Region

#Region "TextBox Properties"
    Private Sub DisableRightClickInTextBox()
        DisableRightClickInfTextEditor(txtClientName)
        DisableRightClickInfTextEditor(txtMarketCap)
        'DisableRightClickInfTextEditor(txtCapGroup)
        DisableRightClickInfTextEditor(txtStreet1)
        DisableRightClickInfTextEditor(txtStreet2)
        DisableRightClickInfTextEditor(txtMobile)
        DisableRightClickInfTextEditor(txtTelephone)
        DisableRightClickInfTextEditor(txtEmail)
        DisableRightClickInfTextEditor(txtExt)
        DisableRightClickInfTextEditor(txtPostalCode)
        DisableRightClickInfTextEditor(txtRegion)
        DisableRightClickInfTextEditor(txtFax)
    End Sub
#End Region

#Region "Method GridClient"
    Private Sub BindListingGridClient()
        Dim dtListing As New DataTable
        Dim dataSet As New DataSet
        Dim MsgLog As New System.Text.StringBuilder

        Try
            'dataSet = AddEditClient.GetListingData()
            dtListing = GetGridDataTable()
            AddClientRows(dtListing, 5)
            If dtListing IsNot Nothing Then
                grdClientDetail.DataSource = dtListing.Copy()
            End If
            'grdFormats.DataSource = dtExcel
            'gridDataTable = dtExcel.Copy() ' CType(grdFormats.DataSource, DataTable)
            ''grdFormats.DataBind()
            'SetGridProperties()
        Catch ex As Exception
            MsgBox(ex.Message)
            MsgLog.Append("There is error in FocusTheExistingInstanceOfForm in Client Management.")
            MsgLog.Append(Environment.NewLine)
            MsgLog.Append("Error Details:- ")
            MsgLog.Append(ex.ToString())
            CreateErrorLog(MsgLog)
            MsgLog = Nothing
        Finally
            dtListing = Nothing
            dataSet = Nothing
        End Try
    End Sub

    Private Shared Function GetGridDataTable() As DataTable
        Dim dtable As New DataTable
        dtable.Columns.Add("Listing", Type.GetType("System.String"))
        dtable.Columns.Add("Ratio", Type.GetType("System.Decimal"))
        dtable.Columns.Add("ISIN", Type.GetType("System.String"))
        dtable.Columns.Add("SEDOL", Type.GetType("System.String"))
        dtable.Columns.Add("CUSIP", Type.GetType("System.String"))
        Return dtable
    End Function
    Private Shared Function GetCapGroupData() As DataTable
        Dim data As New DataTable
        data.Columns.Add("CapGroup", Type.GetType("System.String"))
        Dim row As DataRow
        For i As Integer = 0 To 3
            row = data.NewRow()
            If data.Rows.Count = 0 Then
                row.Item(0) = "Small"
            ElseIf data.Rows.Count = 1 Then
                row.Item(0) = "Mid"
            ElseIf data.Rows.Count = 2 Then
                row.Item(0) = "Large"
            ElseIf data.Rows.Count = 3 Then
                row.Item(0) = "Mega"
            End If
            data.Rows.Add(row)
        Next
        Return data
    End Function
    Private Sub AddClientRows(ByRef dtable As DataTable, ByVal count As Integer)
        Dim row As DataRow
        If dtable IsNot Nothing Then
            For i As Integer = 0 To count - 1
                row = dtable.NewRow()
                row.Item(0) = DBNull.Value
                row.Item(1) = DBNull.Value
                row.Item(2) = DBNull.Value
                row.Item(3) = DBNull.Value
                row.Item(4) = DBNull.Value
                dtable.Rows.Add(row)
            Next
        End If
    End Sub

    Private Function setControlToNumeric(ByVal min As Object, ByVal max As Object, ByVal type As NumericType) As UltraNumericEditor
        Dim numericEditor As New UltraNumericEditor()
        numericEditor.MinValue = min
        numericEditor.MaxValue = max
        numericEditor.NumericType = type
        'numericEditor.PromptChar = " "c
        Return numericEditor

    End Function
#End Region

#Region "Methods textbox"

    Private Sub isNumericString(ByVal e As System.Windows.Forms.KeyPressEventArgs)
        Try
            If (e.KeyChar.ToString() = ".") Then
                e.Handled = True
                Return
            End If
            Dim st As String
            If Clipboard.ContainsText() Then
                st = Clipboard.GetText()
                If (BaseClass.CheckNumericString(st) = False) Then
                    e.Handled = True
                    Clipboard.Clear()
                Else
                    e.Handled = False
                End If
            Else
                If (BaseClass.CheckNumeric(e.KeyChar) = False) Then
                    e.Handled = True
                Else
                    e.Handled = False
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            'nonNumberEntered = False
        End Try
    End Sub

    Private Sub isNumericStringForCell(ByVal e As System.Windows.Forms.KeyPressEventArgs)
        Try
            Dim st As String
            If Clipboard.ContainsText() Then
                st = Clipboard.GetText()
                If (BaseClass.CheckNumericString(st) = False) Then
                    e.Handled = True
                    Clipboard.Clear()
                Else
                    e.Handled = False
                End If
            Else
                If (BaseClass.CheckNumeric(e.KeyChar) = False) Then
                    e.Handled = True
                Else
                    e.Handled = False
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            'nonNumberEntered = False
        End Try
    End Sub

#End Region

#Region "TextBox Events"
    Private Sub txtNotes_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtNotes.Enter
        If txtNotes.Text.ToLower.Trim = "notes" Then
            txtNotes.Text = String.Empty
        End If
    End Sub

    Private Sub txtClientName_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtClientName.Enter
        If txtClientName.Text = "Client Name" Then
            txtClientName.Text = String.Empty
        End If
    End Sub

    Private Sub txtExt_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtExt.Enter
        'If txtExt.Text = String.Empty Then
        '    txtExt.Text = "+"
        'Else
        '    If Not txtExt.Text.ToString.Contains("+") Then
        '        txtExt.Text = "+" + txtExt.Text
        '    End If
        'End If
    End Sub

    Private Sub txtExt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtExt.KeyPress
        isNumericString(e)
    End Sub

    Private Sub txtFax_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtFax.KeyPress
        isNumericString(e)
    End Sub

    Private Sub txtMobile_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMobile.Enter
        If txtMobile.Text = String.Empty Then
            txtMobile.Text = "+"
        Else
            If Not txtMobile.Text.ToString.Contains("+") Then
                txtMobile.Text = "+" + txtMobile.Text
            End If
        End If
    End Sub

    Private Sub txtMobile_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMobile.KeyPress
        isNumericString(e)
    End Sub

    Private Sub txtPostalCode_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPostalCode.KeyPress
        isNumericString(e)
    End Sub

    Private Sub txtTelephone_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTelephone.Enter
        If txtTelephone.Text = String.Empty Then
            txtTelephone.Text = "+"
        Else
            If Not txtTelephone.Text.ToString.Contains("+") Then
                txtTelephone.Text = "+" + txtTelephone.Text
            End If
        End If
    End Sub

    Private Sub txtTelephone_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTelephone.KeyPress
        isNumericString(e)
    End Sub

    Private Sub txtMarketCap_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMarketCap.KeyPress
        isNumericString(e)
    End Sub

#End Region

#Region "Combo Tool Tip"

    'Private Sub cmbCity_DropdownItemSelected(ByVal sender As Object, ByVal e As Crystal.CustomControls.ComboToolTip.DropdownItemSelectedEventArgs)
    '    If (e.SelectedItem < 0 Or e.Scrolled) Then
    '        ToolTip1.Hide(cmbCity)
    '    Else
    '        ToolTip1.Hide(cmbCity)
    '        Dim textWidth As Integer = cmbCity.Items(e.SelectedItem)(0).ToString().Length
    '        If textWidth > 20 Then
    '            ToolTip1.Show(cmbCity.Items(e.SelectedItem)(0).ToString(), cmbCity, e.Bounds.Location)
    '        End If
    '    End If
    'End Sub

    'Private Sub cmbCountry_DropdownItemSelected(ByVal sender As Object, ByVal e As Crystal.CustomControls.ComboToolTip.DropdownItemSelectedEventArgs)
    '    If (e.SelectedItem < 0 Or e.Scrolled) Then
    '        ToolTip1.Hide(cmbCountry)
    '    Else
    '        ToolTip1.Hide(cmbCountry)
    '        Dim textWidth As Integer = cmbCountry.Items(e.SelectedItem)(0).ToString().Length
    '        If textWidth > 20 Then
    '            ToolTip1.Show(cmbCountry.Items(e.SelectedItem)(0).ToString(), cmbCountry, e.Bounds.Location)
    '        End If
    '    End If
    'End Sub

    'Private Sub cmbPExchange_DropdownItemSelected(ByVal sender As Object, ByVal e As Crystal.CustomControls.ComboToolTip.DropdownItemSelectedEventArgs)
    '    If (e.SelectedItem < 0 Or e.Scrolled) Then
    '        ToolTip1.Hide(cmbPExchange)
    '    Else
    '        ToolTip1.Hide(cmbPExchange)
    '        Dim textWidth As Integer = cmbPExchange.Items(e.SelectedItem)(0).ToString().Length
    '        If textWidth > 20 Then
    '            ToolTip1.Show(cmbPExchange.Items(e.SelectedItem)(0).ToString(), cmbPExchange, e.Bounds.Location)
    '        End If
    '    End If
    'End Sub

    'Private Sub cmbIndustry_DropdownItemSelected(ByVal sender As Object, ByVal e As Crystal.CustomControls.ComboToolTip.DropdownItemSelectedEventArgs)
    '    If (e.SelectedItem < 0 Or e.Scrolled) Then
    '        ToolTip1.Hide(cmbIndustry)
    '    Else
    '        ToolTip1.Hide(cmbIndustry)
    '        Dim textWidth As Integer = cmbIndustry.Items(e.SelectedItem)(0).ToString().Length
    '        If textWidth > 20 Then
    '            ToolTip1.Show(cmbIndustry.Items(e.SelectedItem)(0).ToString(), cmbIndustry, e.Bounds.Location)
    '        End If
    '    End If
    'End Sub

    'Private Sub cmbSector_DropdownItemSelected(ByVal sender As Object, ByVal e As Crystal.CustomControls.ComboToolTip.DropdownItemSelectedEventArgs)
    '    If (e.SelectedItem < 0 Or e.Scrolled) Then
    '        ToolTip1.Hide(cmbSector)
    '    Else
    '        ToolTip1.Hide(cmbSector)
    '        Dim textWidth As Integer = cmbSector.Items(e.SelectedItem)(0).ToString().Length
    '        If textWidth > 20 Then
    '            ToolTip1.Show(cmbSector.Items(e.SelectedItem)(0).ToString(), cmbSector, e.Bounds.Location)
    '        End If
    '    End If
    'End Sub

    'Private Sub cmbState_DropdownItemSelected(ByVal sender As Object, ByVal e As Crystal.CustomControls.ComboToolTip.DropdownItemSelectedEventArgs)
    '    If (e.SelectedItem < 0 Or e.Scrolled) Then
    '        ToolTip1.Hide(cmbState)
    '    Else
    '        ToolTip1.Hide(cmbState)
    'Dim textWidth As Integer = cmbState.Items(e.SelectedItem)(0).ToString().Length
    '        If textWidth > 20 Then
    '            ToolTip1.Show(cmbState.Items(e.SelectedItem)(0).ToString(), cmbState, e.Bounds.Location)
    '        End If
    '    End If
    'End Sub

#End Region

#Region "ButtonEvents"
    Private Sub btnAddList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddList.Click
        Dim data As DataTable = CType(grdClientDetail.DataSource, DataTable)
        AddClientRows(data, 1)
        grdClientDetail.DataSource = data
    End Sub
#End Region

#Region "Grid Events"

    Private Sub grdClientDetail_AfterCellListCloseUp(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles grdClientDetail.AfterCellListCloseUp
        Dim gridData As New DataTable
        Dim rowsField() As DataRow
        Dim strSelectedField As String
        Dim Id As String = String.Empty
        Dim Listing As String = String.Empty
        Dim dsReturn As New DataSet
        Dim Logmessage As New System.Text.StringBuilder

        Try
            strSelectedField = grdClientDetail.ActiveRow.Cells("Listing").Text.ToString()
            If strSelectedField = String.Empty Then
                Exit Sub
            End If
            If e.Cell.Text.ToString.ToLower = "--new--" Then
                Dim objAddValue As New CrystalCommon.View.AddValue(enmEntityType.Source.ToString(), LKPMaster.LSTNG, "Listing")
                objAddValue.ShowDialog()
                Id = objAddValue.ID
                If Id <> String.Empty Then
                    dsReturn = AddEditClient.GetTopListing(Convert.ToInt16(Id.ToString))
                    If dsReturn IsNot Nothing Then
                        Listing = dsReturn.Tables(0).Rows(0)("Listing").ToString()
                        'Id = dsReturn.Tables(0).Rows(0)("ListingID").ToString()
                        Dim table As DataTable = cmbListing.DataSource
                        If table.Columns.Contains("Listing") Then
                            Dim FilterQuery As String
                            Dim Excel() As DataRow
                            FilterQuery = "Listing ='" + Trim(Listing).Replace("'", "''") + "'"
                            Excel = table.Select(FilterQuery)
                            If Excel.Length = 0 Then
                                table = BaseClass.InsertRowAtLastDataTable(table, Listing, "Listing")

                                cmbListing.Text = Listing
                            Else
                                e.Cell.Value = Excel(0).Item(0).ToString
                            End If
                        End If
                    End If
                Else
                    e.Cell.CancelUpdate()
                End If
            Else
                gridData = grdClientDetail.DataSource
                Dim lstrFieldValue As String = e.Cell.Text ' grdClientDetail.ActiveRow.Cells("Listing").Value.ToString
                rowsField = gridData.Select("[Listing]='" & lstrFieldValue & "'")
                If rowsField.Length > 0 Then
                    If gridData.Rows.IndexOf(rowsField(0)) = grdClientDetail.ActiveRow.Index Then

                    Else
                        MessageBox.Show("Column '" & grdClientDetail.ActiveRow.Cells("Listing").Text & "' has been already selected.", BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                        e.Cell.CancelUpdate() '.Type.Cancel = True '.Cell.CancelUpdate() '.Cancel = True
                        Exit Sub
                    End If
                End If

            End If
        Catch ex As Exception
            Logmessage.Append("There is error in grdClientDetail_AfterCellListCloseUp of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        End Try
    End Sub

    Private Sub grdClientDetail_AfterSelectChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs) Handles grdClientDetail.AfterSelectChange
        If grdClientDetail.Selected.Rows.Count > 1 Then
            MultiRowSelection(False)
        Else
            MultiRowSelection(True)
            EnableDisableUpDownButtons()
        End If
    End Sub

    Private Sub grdClientDetail_BeforeRowUpdate(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelableRowEventArgs) Handles grdClientDetail.BeforeRowUpdate
        Dim gridRow As UltraGridRow = e.Row
        Dim drv As DataRowView = TryCast(gridRow.ListObject, DataRowView)
        Dim row As DataRow = If(drv IsNot Nothing, drv.Row, Nothing)
        If Not CommonCLL.blnRowBlank(row) Then
            If row.Item("Listing").ToString = String.Empty Then
                MessageBox.Show(MessageManager.GetMessage("SELECTLISTING"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                e.Cancel = True
            ElseIf row.Item("Ratio").ToString = String.Empty Then
                MessageBox.Show(MessageManager.GetMessage("ENTER_RATIO"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                e.Cancel = True
            ElseIf row.Item("ISIN").ToString = String.Empty And row.Item("SEDOL").ToString = String.Empty Then
                MessageBox.Show("Please enter the ISIN or SEDOL.", BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                e.Cancel = True
            End If
        Else
            e.Row.Delete()
        End If
    End Sub

    Private Sub grdClientDetail_ClickCell(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ClickCellEventArgs) Handles grdClientDetail.ClickCell
        EnableDisableUpDownButtons()
    End Sub


    Private Sub grdClientDetail_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles grdClientDetail.InitializeLayout
        Dim Logmessage As New System.Text.StringBuilder

        Try
            e.Layout.Bands(0).Columns("Listing").EditorComponent = Me.cmbListing
            e.Layout.Bands(0).Columns("Listing").CellAppearance.BorderAlpha = Alpha.UseAlphaLevel
            e.Layout.Bands(0).Columns("Listing").ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always
            Me.grdClientDetail.DisplayLayout.Bands(0).Columns("Listing").Style = UltraWinGrid.ColumnStyle.DropDownList

            e.Layout.Bands(0).Columns("Ratio").Format = "####.####"
            e.Layout.Bands(0).Columns("Ratio").MinValue = 0.0001 ' .Format = "nnnn.nnnn"
            e.Layout.Bands(0).Columns("Ratio").MaxValue = 1000.0
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in grdClientDetail_AfterCellListCloseUp of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        End Try
    End Sub
#End Region

    Private Sub cmbCountry_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCountry.SelectionChanged
        If IsLoading = False Then
            If cmbCountry.Value <> Nothing Then
                If cmbCountry.SelectedIndex <> AddEditClient.selectedValue Then
                    FillCityStateRegion()
                End If
            End If
        End If

    End Sub

#Region "Save Method"
    Private Function IsRowExist() As Boolean
        Dim ldtProjects As DataTable
        If grdClientDetail.Rows.Count > 0 Then
            ldtProjects = (CType(grdClientDetail.DataSource, DataTable))
            For i As Integer = 0 To ldtProjects.Rows.Count - 1
                If Not CommonCLL.blnRowBlank(ldtProjects.Rows(i)) Then
                    Return True
                End If
            Next
        End If
        Return False
    End Function
    Protected Function CreateListingXML(ByVal ldtProjects As DataTable) As StringBuilder
        Dim i As Integer
        Dim Logmessage As New System.Text.StringBuilder

        'Dim ldtProjects As DataTable
        Dim sbXML As New StringBuilder
        Try
            If ldtProjects.Rows.Count > 0 Then
                ' ldtProjects = (CType(grdClientDetail.DataSource, DataTable))
                sbXML.Append("<Root>")
                For i = 0 To ldtProjects.Rows.Count - 1
                    If Not CommonCLL.blnRowBlank(ldtProjects.Rows(i)) Then
                        sbXML.Append("<Row ListingName=""" & ldtProjects.Rows(i)(0).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "Ratio=""" & ldtProjects.Rows(i)(1).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "ISIN=""" & ldtProjects.Rows(i)(2).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "SEDOL=""" & ldtProjects.Rows(i)(3).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "CUSIP=""" & ldtProjects.Rows(i)(4).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                                 "SequenceID=""" & (i + 1).ToString().Replace("'", "&apos;").Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace(ControlChars.Quote, "&quot;") & """ " & _
                             "/>")
                        sbXML.Append(vbNewLine)
                    End If

                Next
                sbXML.Append("</Root>")

            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in grdClientDetail_AfterCellListCloseUp of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        End Try
        Return sbXML
    End Function

    Private Sub AddUpdateClient(ByVal Id As Integer)
        Dim Logmessage As New System.Text.StringBuilder
        Dim obj As New AddEditClient
        Try
            obj.cClientID = Id
            obj.cClientName = txtClientName.Text.Trim
            obj.cListing = CreateListingXML(CType(grdClientDetail.DataSource, DataTable)).ToString
            obj.cSectorID = cmbSector.Value
            obj.cIndustryID = cmbIndustry.Value
            obj.cMarketCap = txtMarketCap.Text
            obj.cCapGroup = cmbCapGroup.Text
            obj.cPrimaryExchangeID = cmbPExchange.Value
            obj.cStreet1 = txtStreet1.Text
            obj.cStreet2 = txtStreet2.Text
            obj.cCityId = cmbCity.Value
            obj.cStateId = cmbState.Value
            obj.cCountryId = cmbCountry.Value
            obj.cPostalCode = txtPostalCode.Text
            obj.cMobile = txtMobile.Text
            obj.cTelephone = txtTelephone.Text
            obj.cExt = txtExt.Text
            obj.cFax = txtFax.Text
            obj.cEmail = txtEmail.Text
            If txtNotes.Text = "Notes" Then
                obj.cNotes = String.Empty
            Else
                obj.cNotes = txtNotes.Text.Trim
            End If
            obj.cCreatedBy = 1
            obj.cModifiedBy = 1
            clientID = obj.InsertClient()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Logmessage.Append("There is error in AddUpdateClient of form findmanagement.")
            Logmessage.Append(Environment.NewLine)
            Logmessage.Append("Error Message - ")
            Logmessage.Append(ex.ToString())
            Me.LogErrorToDatabase(Logmessage.ToString)
        Finally
            obj = Nothing
        End Try
    End Sub
#End Region

    Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Try
            ValidationManager.IsButtonClick = True
            If IsValid() Then
                Return
            End If
            If grdClientDetail Is Nothing Then
                MessageBox.Show(MessageManager.GetMessage("NULL_LISTING"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            ElseIf Not IsRowExist() Then
                MessageBox.Show(MessageManager.GetMessage("NULL_LISTING"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End If
            If txtClientName.Text = "Client Name" Then
                MessageBox.Show("Please enter client name.", BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End If
            Dim Id As Integer = 0
            Dim IdExist = Int32.TryParse(Client, Id)
            If AddEditClient.IsClientNameExist(txtClientName.Text.Trim, Id) = False Then
                AddUpdateClient(Id)
                If Id = 0 Then
                    MessageBox.Show(MessageManager.GetMessage("CLIENTCREATED"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Else
                    MessageBox.Show(MessageManager.GetMessage("CLIENTUPDATED"), BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If
                RaiseEvent AddParticularClientInGrid(Client)
                IsSaved = True
                If Id = 0 Then
                    If (MessageBox.Show(MessageManager.GetMessage("CREATE_PROJECT_FROM_CLIENT"), BaseClass.crystalCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information) = Windows.Forms.DialogResult.Yes) Then
                        Dim frmProject As New frmAddEditProject
                        frmProject.Text = "Crystal - Add Project"
                        frmProject.ClientID = clientID
                        frmProject.Show()
                    End If
                End If
                ' Me.Close()
            Else
                MessageBox.Show("Client name already exist.", BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

    Private Sub btnUpList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpList.Click
        If Not IsRowExist() Then
            Exit Sub
        End If
        If grdClientDetail.Rows.Count = 1 Then
            Exit Sub
        End If
        Dim index As Integer = grdClientDetail.ActiveRow.Index
        Dim dataTable As DataTable = CType(grdClientDetail.DataSource, DataTable)
        Dim dRow As DataRow = dataTable.NewRow()
        'dRow = dataTable.Rows(index - 1)
        If CommonCLL.blnRowBlank(dataTable.Rows(index)) Then
            Exit Sub
        End If
        For i As Integer = 0 To dataTable.Columns.Count - 1
            dRow(i) = dataTable.Rows(index - 1)(i).ToString
        Next
        dataTable.Rows.RemoveAt(index - 1)
        dataTable.Rows.InsertAt(dRow, index)
        EnableDisableUpDownButtons()
    End Sub

    Private Sub btnDownList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownList.Click
        If Not IsRowExist() Then
            Exit Sub
        End If
        If grdClientDetail.Rows.Count = 1 Then
            Exit Sub
        End If
        Dim index As Integer = grdClientDetail.ActiveRow.Index
        Dim dataTable As DataTable = CType(grdClientDetail.DataSource, DataTable)
        Dim dRow As DataRow = dataTable.NewRow()
        'dRow = dataTable.Rows(index - 1)
        If CommonCLL.blnRowBlank(dataTable.Rows(index + 1)) Then
            Exit Sub
        End If
        For i As Integer = 0 To dataTable.Columns.Count - 1
            dRow(i) = dataTable.Rows(index + 1)(i).ToString
        Next
        dataTable.Rows.RemoveAt(index + 1)
        dataTable.Rows.InsertAt(dRow, index)
        EnableDisableUpDownButtons()
    End Sub

    Private Sub cmbIndustry_CursorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbIndustry.CursorChanged

    End Sub

    Private Sub cmbIndustry_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbIndustry.LocationChanged
        'e.
    End Sub

    Private Sub cmbIndustry_MouseEnterElement(ByVal sender As Object, ByVal e As Infragistics.Win.UIElementEventArgs) Handles cmbIndustry.MouseEnterElement
        'If TypeOf e.Element Is Infragistics.Win.UltraWinTree.NodeTextUIElement Then
        '    Dim pt As New Point(e.Element.Rect.X, e.Element.Rect.Y)
        '    Dim node As Infragistics.Win.UltraWinTree.UltraTreeNode = cmbIndustry.GetNodeFromPoint(pt)

        '    If Not node Is Nothing Then
        '        Dim tipInfo As New Infragistics.Win.UltraWinToolTip.UltraToolTipInfo(node.Text, Infragistics.Win.ToolTipImage.Default, "", Infragistics.Win.DefaultableBoolean.True)
        '        UltraToolTipManager1.SetUltraToolTip(UltraTree1, tipInfo)
        '        UltraToolTipManager1.ShowToolTip(UltraTree1)
        '    End If

        'Else
        '    UltraToolTipManager1.HideToolTip()

        'End If

        'If e.Element.SelectableItem IsNot Nothing Then
        '    'Dim test As String = e.Element.SelectableItem.ToString  '.ToolTipItem.ToString()
        '    MessageBox.Show(e.Element.ToString)
        'End If
    End Sub


    Private Sub txtFax_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFax.Leave
        If txtFax.Text.Length > 0 Then
            If Not txtFax.Text.Contains("+") Then
                txtFax.Text = "+" + txtFax.Text
            End If
        End If
    End Sub

    Private Sub txtMobile_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMobile.Leave
        If txtMobile.Text.Length > 0 Then
            If Not txtMobile.Text.Contains("+") Then
                txtMobile.Text = "+" + txtMobile.Text
            End If
        End If
    End Sub

    Private Sub txtTelephone_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTelephone.Leave
        If txtTelephone.Text.Length > 0 Then
            If Not txtTelephone.Text.Contains("+") Then
                txtTelephone.Text = "+" + txtTelephone.Text
            End If
        End If
    End Sub

    Private Sub grdClientDetail_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles grdClientDetail.KeyPress
        If grdClientDetail IsNot Nothing Then
            If grdClientDetail.ActiveRow IsNot Nothing Then
                If grdClientDetail.ActiveCell IsNot Nothing Then
                    If grdClientDetail.ActiveCell.Column.Key = "Ratio" Then
                        isNumericStringForCell(e)
                    End If
                End If
            End If
        End If
    End Sub
End Class
'Public Class DropdownItemSelectedEventArgs
'    Inherits EventArgs
'    Private mItem As Integer
'    Private mPos As Rectangle
'    Private mScroll As Boolean
'    Public Sub New(ByVal item As Integer, ByVal pos As Rectangle, ByVal scroll As Boolean)
'        mItem = item
'        mPos = pos
'        mScroll = scroll
'    End Sub
'    Public ReadOnly Property SelectedItem() As Integer
'        Get
'            Return mItem
'        End Get
'    End Property
'    Public ReadOnly Property Bounds() As Rectangle
'        Get
'            Return mPos
'        End Get
'    End Property
'    Public ReadOnly Property Scrolled() As Boolean
'        Get
'            Return mScroll
'        End Get
'    End Property
'End Class